package cn.fanyamin.web.struts;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.fanyamin.business.TaskService;
import cn.fanyamin.domain.Goal;
import cn.fanyamin.domain.Task;
import cn.fanyamin.domain.User;


public class IndexAction extends SecureBaseAction {
    private static Log logger = LogFactory.getLog(IndexAction.class);
    
	public ActionForward list(
	        ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
	            throws java.lang.Exception {
	        
	    TaskService taskService = getWebApp().getTaskService();
        User user = getUserFromSession(request);
        List<Task> taskList = taskService.list(user.getUserID());
        request.setAttribute("taskList", taskList);
        
        List<Goal> goalList = taskService.getAllGoalList(user.getUserID());
        request.setAttribute("goalList", goalList);
        
	    return mapping.findForward("welcome");
	        
	}
}
